/*
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 3 of the License
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *    You should have received a copy of the GNU General Public License
 *    along with this program; if not, write to the Free Software Foundation,
 *    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 */

package JET.Frames.DataModels;

import JET.VirtualKeyboard.VKey;
import java.awt.event.KeyEvent;
import javax.swing.DefaultListModel;

/**
 *
 * @author 057Ry
 */
public class KeyActionsListModel extends DefaultListModel
{

    private VKey vKey;
    private int eventType;

    public KeyActionsListModel(VKey key, int eventType)
    {
        this.vKey = key;
        this.eventType = eventType;
    }

    @Override
    public int getSize()
    {
        switch( eventType )
        {
            case KeyEvent.KEY_PRESSED :
                return vKey.getPressActions().size();
            case KeyEvent.KEY_RELEASED :
                return vKey.getReleaseActions().size();
        }

        return 0;
    }

    @Override
    public Object getElementAt(int index)
    {
        switch( eventType )
        {
            case KeyEvent.KEY_PRESSED :
                return vKey.getPressActions().get(index);
            case KeyEvent.KEY_RELEASED :
                return vKey.getReleaseActions().get(index);
        }

        return null;
    }

}
